package com.mijie.homi.search;


import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;


import com.mijie.homi.search.api.UserSearchApi;
import com.mijie.homi.search.service.index.ClrRecently;
import com.mijie.homi.search.service.index.MoodUserIndexService;
import com.mijie.homi.search.util.god;
import com.mijie.homi.search.util.pagingController;
import com.mijie.query.sincinController;

import static com.mijie.homi.search.service.index.MoodUserIndexService.*;

//@Resource(type = SearchResultProser.class)  //(value = "SearchResultProserCmpt")
@Component
public class SearchResultProserx extends SearchResultProser {

	@Resource (name="moodUserIndexService") 
	MoodUserIndexService matchService;
	public int offset;
	public int limit;
	public int userId;
	public Map<String, Map> msgs_mp;
	public List<String> moodIds_li;
	public List<Map> msg_wait_hid_byMktDelPrblm;

	public List<Map> del_Msg_ByHeminLen;

	public Map<String, Map> moods_mp;

	// private List<String> del_sincin_markDelete_set;
	// private List<Map> msg_del_by_gender;
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			SearchResultProserx c = (SearchResultProserx) UserSearchApi
					.getbean("searchResultProserx");
			// List<Map> li = .selectList("getRecently100", nowId);

			System.out.println(c);
			c.start();
			System.out.println("f");
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			System.exit(0);
		}

	}

	private void start() {
		System.out.println("ooo");

	}

	public List process(List<Map> r2) {
		// Nbo order by pipeidu,createAt ,ar only pipeidu
		try {
			matchService.orderByCreateTime(r2);

		} catch (Exception e) {
			matchService.logger.info(god.getTrace(e));
		}
		// nbp order by active user
		// r2 = order_by_active_user(r2);
		// logger.info("  return all:" + r2.size());

		// ///
		List<Map> li3 = r2;
		// tbn hide not public
		// li3 = exceptHide(li3, moodIds_except, prblmIds_except);
		// //
		// Nbo del prblm if sincin jenmye
		// try {
		// if (sincinController.isJenmyerSincin(mood.getMood()))
		// li3 = del_prblm(prblmIds_li, li3, moods_mp);
		// } catch (Exception e) {
		// logger.info(god.getTrace(e));
		// }

		// Nbp del sincin markDelete
		// li3 = del_sincin_markDelete(del_sincin_markDelete_set, li3,
		// moods_mp);

		// nbt del bpipei d sincinN prblm by hemin len
		li3 = del_byHeminLen(del_Msg_ByHeminLen, li3);

		// o11
		// li3 = delMsg_by_gender(msg_del_by_gender, li3);

		// o11 duli user
		// de duli user
		// userID_deduli_set = new HashSet<String>();
		// msg_wait_del_byDuliUser = new ArrayList<Object>();
		// for (Map m : li3) {
		//
		// String uid_s = String.valueOf(m.get("userId"));
		//
		// if (userID_deduli_set.contains(uid_s))
		// msg_wait_del_byDuliUser.add(m);
		// userID_deduli_set.add(uid_s);
		// }

		// li3 = delMsg_by_byDuliUser(msg_wait_del_byDuliUser, li3);

		// o12
		// li3 = delMsg_by_byAnonymosPrblm(msg_wait_hid_byAnonymosPrblm, li3);
		li3 = delMsg_by_byMktDelPrblm(msg_wait_hid_byMktDelPrblm, li3);
		// li3 = delMsg_block_sincin(block_sincin, li3);
		// o16
		li3 = delMsg_dedw(li3);

		// o17 except uid
		li3 = except_self(li3, userId, msgs_mp, moodIds_li);

		// List<Map> li3 =ftc. except_uidByMids(sincinIds_set, new
		// ArrayList<String>(), li3);

		// tbn paging.

		// int toindex = offset + limit;
		// int size = r2.size();
		// if (offset >= size) {
		// offset = size - 1;
		// toindex = offset;
		// } else {
		// if (toindex > size)
		// toindex = size - 1;
		// }

		List<Map> li4 = pagingController.newPage(offset, limit, li3);
		// li4 = countDistans(userId, li4);
		return li4;

	}

//	public void setParam(int offset2, int limit2, int userId2,
//			Map<String, Map> msgsMp, List<String> moodIdsLi,
//			List<String> moodIdsLi2, List msgWaitHidByMktDelPrblm,
//			List delMsgByHeminLen, Map<String, Map> moodsMp) {
//		this.offset = offset2;
//		this.limit = limit2;
//		this.userId = userId2;
//		this.msgs_mp = msgsMp;
//		this.moodIds_li = moodIdsLi;
//		this.msg_wait_hid_byMktDelPrblm = msgWaitHidByMktDelPrblm;
//		this.del_Msg_ByHeminLen = delMsgByHeminLen;
//		this.moods_mp = moodsMp;
//
//	}

}
